{% extends "layout.html" %} {% block title %}上传AWR报告{% endblock %} {% block
content %}
<header class="text-center mb-8">
  <h1 class="text-4xl font-bold text-gray-900">AWR 报告智能分析工具</h1>
  <p class="text-lg text-gray-600 mt-2">
    上传您的AWR报告 (HTML或TXT格式)，立即获取性能分析摘要和优化建议。
  </p>
</header>

{% with messages = get_flashed_messages() %} {% if messages %}
<div
  class="max-w-3xl mx-auto bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded relative mb-4"
  role="alert"
>
  <strong class="font-bold">错误!</strong>
  <span class="block sm:inline">{{ messages[0] }}</span>
</div>
{% endif %} {% endwith %}

<div class="max-w-3xl mx-auto">
  <form
    action="{{ url_for('analyze') }}"
    method="post"
    enctype="multipart/form-data"
  >
    <div
      class="border-2 border-dashed border-gray-300 rounded-lg p-8 text-center bg-white"
    >
      <svg
        class="mx-auto h-12 w-12 text-gray-400"
        stroke="currentColor"
        fill="none"
        viewBox="0 0 48 48"
        aria-hidden="true"
      >
        <path
          d="M28 8H12a4 4 0 00-4 4v20m32-12v8m0 0v8a4 4 0 01-4 4H12a4 4 0 01-4-4V12a4 4 0 014-4h12l4 4h12a4 4 0 014 4z"
          stroke-width="2"
          stroke-linecap="round"
          stroke-linejoin="round"
        ></path>
      </svg>
      <label for="awr_file" class="mt-4 text-lg text-gray-600 cursor-pointer">
        点击此处选择文件
      </label>
      <p class="mt-1 text-sm text-gray-500">或将文件拖拽到这里</p>
      <input
        type="file"
        name="awr_file"
        id="awr_file"
        class="sr-only"
        required
      />
      <p id="file-name" class="mt-2 text-sm font-medium text-gray-600"></p>
      <button
        type="submit"
        class="mt-4 inline-flex items-center px-6 py-3 border border-transparent text-base font-medium rounded-md shadow-sm text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500"
      >
        开始分析
      </button>
    </div>
  </form>
</div>

<script>
  document.getElementById("awr_file").addEventListener("change", function () {
    var fileName = this.files[0] ? this.files[0].name : "未选择文件";
    document.getElementById("file-name").textContent = "已选择: " + fileName;
  });
</script>
{% endblock %}
